#ifndef FMOD_ENGINE_H
#define FMOD_ENGINE_H

#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <vector>
#include <map>
#include <assert.h>
#include "Singleton.h"
#include "fmod/fmod.hpp"
#include "fmod/fmod_errors.h"
#pragma comment (lib, "fmod/fmodex_vc.lib")

using namespace FMOD;

class FmodEngine
{
public:
	void Init();
	void Update();
	void Cleanup();

	//these functions included as back ups and for anything not covered by the other functions
	System* GetSystem(){return m_pSystem;}
	Channel* GetMusicChannel(){return m_pMusicChannel;}
	ChannelGroup* GetEffectsChannels(){return m_EffectChannels;}
	
	// functions for more then one track (specific for the mixing desk project)
	Sound* LoadMusic(const char* file, Sound* m);
	Channel* PlayMusic(Sound* m, Channel* c);
	Sound* LoadSample(const char* file,char* name, Sound* s);
	Channel* PlaySample(Sound* s,Channel* c);

	//normal functions
	Sound* LoadMusic(const char* file);
	Sound* LoadSample(const char* file, char* name);

	Channel* PlayMusic();
	Channel* PlayMusic(const char* file);//load and play

	
	Channel* PlaySample(char* name);
	Channel* PlaySample(const char* file, char* name);//load and play

	void SetPauseMusic(bool b);
	void SetPauseAll(bool b);

	void SetMasterVolume(float f);
	void AdjustMasterVolume(float f);
	float GetMasterVollume(){return m_MasterVolume;}

	void SetMusicVolume(float f);
	void AdjustMusicVolume(float f);
	float GetMusicVollume(){return m_MusicVolume;}

	void SetEffectVolume(float f);
	void AdjustEffectVolume(float f);
	float GetEffectVollume(){return m_EffectVolume;}

private:
	FmodEngine(){}
	friend class Singleton<FmodEngine>;

	System		*m_pSystem;
	Channel		*m_pMusicChannel;
	ChannelGroup*m_EffectChannels;
	Sound		*m_pMusic;
	std::map<char*, Sound*> m_pSamplesMap;
	float m_MasterVolume; //the maximum volume anything will be
	float m_MusicVolume;
	float m_EffectVolume;

};

typedef Singleton<FmodEngine> TheAudio;

#endif